[Top] [Prev] [Next] [Bottom] [Contents]

Creating a DSQL Object Binding

4. From the Project Window, click the Object Bind Editor (New Activator) icon. The Activator Selector window will appear (Fig. 4-2).

Figure 4-2 Activator Selector Window

5. From the Document list select home.html.
6. From the Anchors list select HREF=books. Click Ok.
7. The Open Procedure window appears (Fig. 4-3).

Figure 4-3 Open DSQL window

8. Click the down arrow at Object Type and select DSQL.
9. Select your database server from the Server list.
10. You will be prompted for your database username and password.
Note: If you are unsure of your username and password, see your Database Administrator.
11. Select pubs2 from the Database list.
12. Select BD_Get_Title_Types from the DSQL Name list.
13. Click Ok. The Object Bind Editor Window will appear.
14. Examine the information in this window to verify that you have selected the correct data object (a DSQL object named BD_Get_Title_Types) and that it is bound to the correct activator (the books anchor in home.html).
15. At Results<=>Template, select books.html. The books.html document will be displayed and populated with the data from BD_Get_Title_Types when the books anchor is clicked.
16. At the type char(12) label click the down arrow and select TitleTypes. If you use the Document Manager to edit books.html, you will see the data site TitleTypes. The data from BD_Get_Title_Types called type will be used to populate the TitleTypes data site.
17. Click the Results Detail button (Fig. 4-4).

Figure 4-4 Object Bind Editor

18. The Results Detail dialog box will appear (Fig. 4-5).

Figure 4-5 Results Detail dialog box

19. Click the down arrow next to Callback and select SaPopulateOptions. You can click Help to find out more about this population callback.
20. Click Ok. The population callback function SaPopulateOptions will be used to format the data from the data object before it is used to populate the data site.
21. Click Apply. This will save your changes in memory and reset the change flags in the Object Bind Editor.
22. Click Ok to close the Object Bind Editor.

Setting Project Options

1. From the Project Window select Edit->Options...
2. Click the down arrow next to Category and select Project.
3. Select HTML Start-up Document from the Option list. Change the value to home.html.
4. Click Ok to close the Options Editor.

Testing the Dynamically Populated Menu

1. From the Project Window select File->Save, then click the Test icon.
In the Messages window you will see Sapphire/Web reporting as it writes the HTML files to the disk and compiles and links the generated server applications (tut1.c and home.c).

Figure 4-6 Bluestone Generated Web page

2. Your browser should soon display the first page of the Bookstore (Fig. 4-6). Click the Book Search graphic to activate the first bind. The following occurs transparently:

As Sapphire/Web reads HTML documents, anything it finds that begins with ##Sa_ and ends with ## is considered to be a data site, and the text between the delimiters becomes the name of the site. You can put Data Sites almost anywhere in your HTML documents.

If the results returned from the database contain spaces, then you need to wrap the drop site in quotes as shown:

<INPUT NAME="author" VALUE="##Sa_Author##">

3. The Book Query page is now displayed (Fig. 4-7). Click on the Category box. You will see a populated listing of topics.

Figure 4-7 Dynamically Populated Options Menu

Before you clicked the Book Search graphic, the options menu in books.html only contained a marker that acted as a placeholder for data objects:

<OPTION>##Sa_TitleTypes##</OPTION>
Now the placeholder has been replaced with real values that your DSQL object retrieved from your database.



[Top] [Prev] [Next] [Bottom] [Contents]

info@bluestone.com
Copyright © 1997, Bluestone. All rights reserved.